/**
 * @a https://leetcode.cn/problems/last-stone-weight/description/
 */




#include "../common.h"

class Solution {
public:
    int lastStoneWeight(vector<int>& stones) {
        priority_queue<int> pq(stones.begin(),stones.end(), less<int>());
        while(pq.size() >= 2){
            int y = pq.top();
            pq.pop();
            int x = pq.top();
            pq.pop();
            pq.push(y - x);
        }
        return pq.top();
    }
};